// 获取路由权限
import {commGet, commPost, deleteAction} from "@utils/service/index.js";

export function getUserPermissionByTokenApi() {
    return commGet({
        url: "/sys/permission/getUserPermissionByToken",
        method: 'get',
    })
}
export function getPermissionList(data) {
    return commGet({
        url: "/sys/permission/list",
        method: 'get',
        data
    })
}
export function getSysAppList(data) {
    return commGet({
        url: "/sys/sysApp/list",
        method: 'get',
        data
    })
}

/**
 * 查询菜单树状结构
 * @param data
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export function queryTreeList(data) {
    return commGet({
        url: "/sys/permission/queryTreeList",
        method: 'get',
        data
    })
}

/**
 * 添加菜单列表
 * @param data
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export function addPermissionTree(data) {
    return commPost({
        url: "/sys/permission/add",
        method: 'post',
        data
    })
}

/**
 * 批量删除菜单列表
 * @param data
 * @param url 请求的url
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export function deleteBatch(url,data) {
    return deleteAction({
        url: url,
        data
    })
}

/**
 * 删除单条数据
 * @param data
 * @param url 请求的url
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export function deleteOne(url,data) {
    return deleteAction({
        url: url,
        data
    })
}

/**
 * 编辑菜单树
 * @param data
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export function editPermissionTree(data) {
    return commPost({
        url: "/sys/permission/edit",
        method: 'post',
        data
    })
}

/**
 * 查询角色权限列表
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export function queryRoleTreeList(data) {
    return commGet({
        url: "/sys/role/queryTreeList",
        method: 'get',
        data
    })
}

/**
 * 查询角色权限
 * @returns {Promise<axios.AxiosResponse<any>>}
 */
export function queryRolePermission(data) {
    return commGet({
        url: "/sys/permission/queryRolePermission",
        method: 'get',
        data
    })
}
